package com.nguc.ngucpractice.controller;

import com.nguc.ngucpractice.common.controller.BaseController;
import com.nguc.ngucpractice.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

/**
 * User:曹帅
 * Date:2020/8/2
 * Version:1.0
 */
@RestController
@RequestMapping("/manage/category")
public class CategoryController extends BaseController {

    @Autowired
    private CategoryService categoryService;


    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public ModelAndView findAll(@RequestParam(name = "parentId", defaultValue = "0") Integer parentId) {
        return feedback(categoryService.findListByParentId(parentId));
    }

    @RequestMapping(value = "/info", method = RequestMethod.GET)
    public ModelAndView findInfo(@RequestParam(name = "categoryId", defaultValue = "") Integer categoryId) {
        return feedback(categoryService.findCategoryById(categoryId));
    }

}
